package com.power.flowable.api;

import com.plf.common.domain.ResponseDTO;
import com.power.flowable.model.pageinfo.ProcessInstancePageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 业务管理相关接口
 * @author wangning
 *
 */
@FeignClient(value = "sfflow-svr", contextId = "sfflow-svr", path = "/sfflow-svr")
@RestController
public interface ITaskFeign {

	/**
	 * 查询所有的待处理业务列表
	 * @return
	 */
	@PostMapping("flow/allTaskList")
	ResponseDTO allTaskList();


	/**
	 * 根据userid,查询进行中/已完成的流程业务列表
	 * @param userid
	 * @param pageinfo 查询条件page.state=1 进行中=2已完成
	 * @return
	 */
	@PostMapping("flow/findProcessInstanList")
	ResponseDTO findProcessInstanList(@RequestParam(required = false)  String userid, @RequestBody ProcessInstancePageInfo pageinfo);

	/**
	 * 查看进行中业务详情
	 * @param taskid (对应act_ru_task表_id字段)
	 * @return
	 */
	@PostMapping("flow/viewConductTask")
	ResponseDTO viewConductTask(@RequestParam String taskid);

	/**
	 * 查看完成(结束)的业务详情
	 * @param taskid
	 * @return
	 */
	@PostMapping("flow/viewEndTask")
	ResponseDTO viewEndTask(@RequestParam String taskid);

	/**
	 *根据userid查询我需要处理的业务数
	 * @param userid
	 * @return
	 */
	@PostMapping("flow/mypendingBusinessCount")
	ResponseDTO mypendingBusinessCount(@RequestParam(required = true) String userid);

	/**
	 * 查询流程实例状态, 历史表中根据完成时间是否为空, 判断total>0条进行中, total=0已完成
	 * @param processinstanceid 流程实例id
	 * @return {"suspensionState":>0='进行中' 2='暂停', total: Integer 总记录数}
	 */
	@PostMapping("flow/findProcessStart")
	ResponseDTO findProcessStart(@RequestParam(required = true) String processinstanceid);

	/**
	 * 查询流程实例的状态
	 * @param processinstanceid 流程定义id(对应act_ru_task表的PROC_DEF_ID_字段)
	 * @return	Boolean -> true 结束， false 未结束
	 */
	@PostMapping("flow/findProcessIsEnd")
	ResponseDTO findProcessIsEnd(@RequestParam(required = true) String processinstanceid);

	/**
	 * 查询最后一个流程任务的taskid
	 * @param processinstanceid
	 * @return
	 */
	@PostMapping("flow/queryLastTaskidByInstid")
	ResponseDTO queryLastTaskidByInstid(@RequestParam String processinstanceid);
}
